package com.example.goodpet.db.dao;

import androidx.room.Dao;
import androidx.room.Delete;
import androidx.room.Insert;
import androidx.room.OnConflictStrategy;
import androidx.room.Query;

import com.example.goodpet.db.entity.GoodpetHistory;
import com.example.goodpet.db.entity.User;

import java.util.List;
@Dao
public interface GoodpetHistoryDAO {
    @Insert(onConflict = OnConflictStrategy.REPLACE)
    void insert(GoodpetHistory goodpetHistory);

    @Query("delete from goodpet_history where userId = :userId")
    void delete(long userId);

    @Query("select * from goodpet_history where userId = :userId ORDER BY postdate DESC")
    List<GoodpetHistory> selectListHistory(long userId);

    /**
     * 删除单个浏览记录
     * @param userId
     * @param petId
     */
    @Query("delete from goodpet_history where userId = :userId and petId = :petId")
    void deleteByUserIdAndPetId(long userId,long petId);

}
